package cn.car91.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.car91.R;

public class IllegalAreaAdapter extends BaseAdapter {

    public class Area {
        public String id;
        public String name;
    }

    public Area instanceArea() {
        return new Area();
    }

    private List<Area> mList;
    private Context mContext;

    public IllegalAreaAdapter(Context pContext) {
        this.mContext = pContext;
        this.mList = new ArrayList<Area>();
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mList.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return mList.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {
        // TODO Auto-generated method stub
        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        arg1 = layoutInflater.inflate(R.layout.view_area_spinner, null);

        if (arg1 != null) {
            TextView aid = (TextView) arg1.findViewById(R.id.area_id);
            TextView aname = (TextView) arg1.findViewById(R.id.area_name);
            aname.setGravity(Gravity.CENTER);
            aid.setText(mList.get(arg0).id);
            aname.setText(mList.get(arg0).name);
        }

        return arg1;
    }

    public List<Area> getmList() {
        return mList;
    }

    public void setmList(List<Area> mList) {
        this.mList = mList;
    }


}
